<?php



namespace App\Services\Business\Models;

use App\Services\Business\Models\Base;
use App\Services\Business\Models\Comment;
use App\Services\Business\Models\ThumbsUp;
use App\Services\Member\Models\Activity;
use App\Services\Member\Models\User;
use Illuminate\Support\Facades\Auth;


class WishFragment extends Base
{


    protected $table = 'wish_fragment';



    protected $fillable = [
        'user_id', 'wish_id','title',"thumbsup_count",'favorite_count','comments_count','total_point','point','wish_reward'
    ];

    protected $hidden = [
        'deleted_at',
    ];

    public function setWishRewardAttribute($value)
    {
        // 序列化数据并存储到数据库中
        $this->attributes['wish_reward'] = serialize($value);
    }


    public function getWishRewardAttribute($value)
    {
        // 反序列化数据
        return unserialize($value);
    }


    //发布动态的人
    public function user()
    {
        return $this->belongsTo(User::class, 'user_id', 'id');
    }


    public function wish()
    {
        return $this->belongsTo(Wish::class, 'wish_id');
    }



    public function images()
    {
        return $this->morphMany(Image::class, 'imageable');
    }


    public function videos()
    {
        return $this->morphToMany(Video::class, 'videoable');
    }

    public function comments()
    {
        return $this->morphMany(Comment::class, 'commentable');
    }

    public function thumbsups()
    {
        return $this->morphMany(ThumbsUp::class, 'thumbsupable');
    }

    public  function  activity()
    {
        return $this->morphMany(Activity::class, 'activityable');
    }







}
